﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteMaster.Master" AutoEventWireup="true" CodeBehind="Profiles.aspx.cs" Inherits="ThrongIn.Profiles" %>
<%@ Register src="UserControls/ProfileList.ascx" tagname="ProfileList"  tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        var offset = 0;
        var limit = 8;
        var count = $('#<%=hidPage.ClientID %>').val()
        if (count < (offset + limit)) {
            $('#btnMore').addClass('display-none');
            $('#btnMore').removeClass('buttonMoreDetails');
            $('#imgProcessing').addClass('display-none');
        }
        else {
            $('#btnMore').addClass('buttonMoreDetails');
            $('#btnMore').removeClass('display-none');
            $('#imgProcessing').addClass('display-none');
        }
        $('#btnMore').click(function () {            
            $('#btnMore').addClass('display-none');
            $('#imgProcessing').removeClass('display-none');
            $('#imgProcessing').parent().addClass('center');
            var ControlName = "ProfileList.ascx";
            offset = 0;
            offset = parseInt($('#hidPageCount').val());
            offset = offset + 8;
            //var limit = 8;
            var parentId = $('#<%=hidProfileId.ClientID %>').val();
            $('#hidPageCount').val(offset);

            makeAJAXCall("POST", "Profiles.aspx/LoadUserControl", "{controlName:'" + ControlName + "',limit:" + limit + ",offset:" + offset + ",parentId:" + parentId + "}", DisplayProfiles, OnError);

        });

        function DisplayProfiles(response) {
            var count = $('#<%=hidPage.ClientID %>').val()
            if (count < (offset + limit)) {
                $('#btnMore').addClass('display-none');
                $('#btnMore').removeClass('buttonMoreDetails');
                $('#imgProcessing').addClass('display-none');
                $('#imgProcessing').parent().removeClass('center');
            }
            else {
                $('#btnMore').addClass('buttonMoreDetails');
                $('#btnMore').removeClass('display-none');
                $('#imgProcessing').addClass('display-none');
            }
            $('#ProfileContainer').append(response.d);
            $('html, body').animate({ scrollTop: $(document).height() }, 'slow');
        }
        function OnError(msg) {
            $('#btnMore').addClass('buttonMoreDetails');
            $('#btnMore').removeClass('display-none');
            $('#imgProcessing').addClass('display-none');
            $('#ProfileContainer').html(msg);
        }

    });
 
</script>

  <!-- begin #mainContent -->         
        <input type="hidden" id="hidPageCount" value="0"/>
        <input type="hidden" id="hidProfileId" runat="server"/>
        <input type="hidden" id="hidPage" runat="server"/>
    	<div id="ProfileContainer" class="clear">
        <div id="divMsg" style="margin-left:2px;width:100%;" runat="server" visible="false"></div>
        <uc1:ProfileList ID="ucProfilePerson" Columns=4 Direction="Horizontal" Layout="Table" runat="server" />
        </div>
    	   
    	<div><img alt="processing..." class="display-none" src="Images/processing.gif" id="imgProcessing" />    	
    	<input type="button" id="btnMore" value="more..." class="buttonMoreDetails" />
    	</div>
        <br class="clearfloat" />

</asp:Content> 